package cn.xiaomubiao.oschine.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import cn.xiaomubiao.oschine.R;
import cn.xiaomubiao.oschine.fragment.Event_fragment.EventBaseFragment;
import cn.xiaomubiao.oschine.fragment.Event_fragment.EventBaseFragment2;

/**
 * Created by King Su on 2017/4/2.
 * 活动
 */

public class EventActivity extends AppCompatActivity {
    List<Fragment> list = new ArrayList<>();
    @BindView(R.id.iv_event_back)
    ImageView mIvEventBack;
    @BindView(R.id.tv_event_title)
    TextView mTvEventTitle;
    @BindView(R.id.event_tbl)
    TabLayout mEventTbl;
    @BindView(R.id.event_viewpager)
    ViewPager mEventViewpager;

    private String[] tabTexts = {"近期活动","我的活动"};
    private Fragment[] eventFragment = {new EventBaseFragment(),new EventBaseFragment2()};

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_event);
        ButterKnife.bind(this);

       /* list.add(new RecentEventFragment());
        list.add(new Content2());*/


        mEventViewpager.setAdapter(new EventPagerAdapter(getSupportFragmentManager()));

        mEventTbl.setupWithViewPager(mEventViewpager);
    }

    @OnClick({R.id.iv_event_back, R.id.event_tbl})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.iv_event_back:
                EventActivity.this.finish();
                break;
            case R.id.event_tbl:
                break;
        }
    }

    class EventPagerAdapter extends FragmentStatePagerAdapter {

        public EventPagerAdapter(FragmentManager fm) {
            super(fm);
        }

        @Override
        public Fragment getItem(int position) {
            return eventFragment[position];
        }

        @Override
        public int getCount() {
            return tabTexts.length;
        }


        @Override
        public CharSequence getPageTitle(int position) {
            return tabTexts[position];
        }
    }

}
